Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solana ChainWriter #935

Open
wants to merge 28 commits into
base: develop
Choose a base branch
from
Open

Solana ChainWriter #935

wants to merge 28 commits into from

Conversation

silaslenihan
Copy link
Contributor

@silaslenihan silaslenihan commented Nov 20, 2024

Description

Related Tickets:
NONEVM-753
NONEVM-963
NONEVM-964

Requires Dependencies

Resolves Dependencies

@silaslenihan silaslenihan force-pushed the BCFR-995-Solana-ChainWriter branch from 8c8a858 to 845a9a6 Compare November 20, 2024 15:31
@silaslenihan silaslenihan force-pushed the BCFR-995-Solana-ChainWriter branch from 845a9a6 to 13cf316 Compare November 20, 2024 15:32
@silaslenihan silaslenihan force-pushed the BCFR-995-Solana-ChainWriter branch from 7332617 to 17379b5 Compare November 21, 2024 20:34
@silaslenihan silaslenihan force-pushed the BCFR-995-Solana-ChainWriter branch from 17379b5 to 93cba43 Compare November 21, 2024 20:39
silaslenihan and others added 15 commits December 24, 2024 09:06
* Added ChainWriter unit tests for GetFeeComponents and GetTransactionStatus

* Created SubmitTransaction tests

* Created SubmitTransaction tests

* Moved txm utils into own package and generated txm mock

* Updated chain writer tests to use txm mock

* Added GetAddresses unit test and fixed SubmitTransaction unit test

* Fixed linting and removed file read for IDL

* Fixed filter lookup table error case and fixed linting

* Added filter lookup table addresses unit tests

* Added new test case and fixed formatting issues

* Addressed golang lint suggestions

* Cleaned out unused dependency and fixed remaining golang lint errors

* Added derived lookup table indeces unit tests

---------

Co-authored-by: Silas Lenihan <[email protected]>
@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
32.0% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube

}

// Enqueue transaction
if err = s.txm.Enqueue(ctx, accounts[0].PublicKey.String(), tx, &transactionID, blockhash.Value.LastValidBlockHeight); err != nil {
Copy link
Contributor

@ilija42 ilija42 Dec 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config doesn't have any validation for accounts lookup having any entries, so wouldn't this panic if one of the methodConfigs has no account lookups listed? You should check for accounts size

return filteredLookupTables
}

func (s *SolanaChainWriterService) SubmitTransaction(ctx context.Context, contractName, method string, args any, transactionID string, toAddress string, meta *types.TxMeta, value *big.Int) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint nit

Suggested change
func (s *SolanaChainWriterService) SubmitTransaction(ctx context.Context, contractName, method string, args any, transactionID string, toAddress string, meta *types.TxMeta, value *big.Int) error {
func (s *SolanaChainWriterService) SubmitTransaction(ctx context.Context, contractName, method string, args any, transactionID string, toAddress string, _ *types.TxMeta, _ *big.Int) error {


for _, seed := range lookup.Seeds {
if lookupSeed, ok := seed.(AccountLookup); ok {
// Get value from a location (This doens't have to be an address, it can be any value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint

Suggested change
// Get value from a location (This doens't have to be an address, it can be any value)
// Get value from a location (This doens't have to be an address, it can be any value)

}

// GetValuesAtLocation parses through nested types and arrays to find all locations of values
func GetValuesAtLocation(args any, location string) ([][]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callers in multiple locations are trying to access response slice elem by index without checking the size which is panic prone

var lookupTableMetas []*solana.AccountMeta

// Iterate over each address of the lookup table
for _, addressMeta := range lookupTableAddresses {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to get empty slice of lookupTableAddresses, if it is is that okay? If not maybe throw an error here

// Read the full list of addresses from the lookup table
addresses, err := getLookupTableAddresses(ctx, reader, addressMeta.PublicKey)
if err != nil {
return nil, nil, fmt.Errorf("error fetching lookup table address: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to also log the table address here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants